home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 May & June / Amiga-CD 1996 #5-6.iso / demos / finaldata / fdmacros / setcolumnwidth < prev    next >
Text File  |  1996-03-22  |  2KB  |  70 lines

  1. /* --------------------------------------------- */
  2. /* Final Data ARexx Macro.                       */
  3. /* SetColumnWidth: This macro will adjust the    */
  4. /*  width of each selected column so that when   */
  5. /*  printed all of the data in the column will   */
  6. /*  be printed. Be sure to have the print pitch  */
  7. /*  set before you run this macro.               */
  8. /* $VER: SetColumnWidth 1.0 (28.6.94)            */
  9. /*                                               */
  10. /* This macro is useful because the font used on */
  11. /*  screen is proportional, whereas the printed  */
  12. /*  font is non-proportional (mono-spaced). This */
  13. /*  makes it difficult to know how wide to make  */
  14. /*  the column so that all the data will get     */
  15. /*  printed. Without this macro it's all done by */
  16. /*  trial and error.                             */
  17. /* --------------------------------------------- */
  18. OPTIONS RESULTS
  19.  
  20. SelectionInfo
  21. PARSE VAR RESULT selType fromCol toCol
  22.  
  23. IF ( selType = 'COLUMNS' ) THEN DO
  24.  
  25.     GetPrintPrefs PITCH DEVICE
  26.     PARSE VAR RESULT prefsPitch prefsDevice
  27.     pitch = 10
  28.     IF ( prefsDevice = 'Printer' ) THEN DO
  29.         SELECT
  30.             WHEN ( prefsPitch = 'Pica' ) THEN DO
  31.                 pitch = 10
  32.                 END
  33.             WHEN ( prefsPitch = 'Elite' ) THEN DO
  34.                 pitch = 12
  35.                 END
  36.             WHEN ( prefsPitch = 'Fine' ) THEN DO
  37.                 pitch = 15
  38.                 END
  39.             OTHERWISE DO
  40.                 END
  41.         END /* Select */
  42.     END
  43.  
  44.     NumRows
  45.     nrows = RESULT
  46.     IF ( nrows > 0 ) THEN DO
  47.  
  48.         DO c = fromCol TO toCol
  49.  
  50.             GetColumnName POSITION c
  51.             maxlen = LENGTH(RESULT)
  52.  
  53.             DO r = 1 TO nrows
  54.                 CellData c r
  55.                 len = LENGTH(RESULT)
  56.                 IF    ( len > maxlen ) THEN
  57.                     maxlen = len
  58.             END /* do to nrows */
  59.  
  60.             pixels = ((maxlen * 80) % pitch) + 1
  61.             GetColumnID POSITION c
  62.             InitModifyColumn RESULT
  63.             DefineColumn WIDTH pixels
  64.             ModifyColumn
  65.  
  66.         END /* do to toCol */
  67.  
  68.     END
  69.  
  70. END